package com.unknow.article.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.unknow.article.dao.IArticleDao;
import com.unknow.article.entity.Article;
import com.unknow.util.db.IDBManage;
import com.unknow.util.db.impl.DBCPManageimpl;

public class ArticleDaoImpl implements IArticleDao {
	
	private Connection conn;
	
	
	
	public ArticleDaoImpl() {
		conn = new DBCPManageimpl().getConnection(); 
	}

	public boolean delete() {
		return false;
	}

	public List findArticleDao(Object criteria) {
		String sql = "select * from tbl_article";
		ResultSet rs = null;
		List result = new ArrayList();
		try {
			Statement stm = conn.createStatement();
			rs = stm.executeQuery(sql);
			while(rs.next()) {
				Article article = new Article();
				article.setId(rs.getInt(1));
				article.setTitle(rs.getString(2));
				result.add(article);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return result;
	}

	public List findById(int id) {
		return null;
	}

	public boolean save() {
		return false;
	}

	public boolean update() {
		// TODO Auto-generated method stub
		return false;
	}

}
